home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / libbsd42 / getcwd.c < prev    next >
C/C++ Source or Header  |  1989-06-27  |  429b  |  31 lines

  1. /*
  2.  * SystemV getcwd simulation on 4.2BSD
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/param.h>
  7.  
  8. /* imports from libc */
  9. extern char *getwd();
  10. extern char *strncpy();
  11.  
  12. char *
  13. getcwd(path, size)
  14. register char *path;
  15. int size;
  16. {
  17.     if (size >= MAXPATHLEN)
  18.         return getwd(path);
  19.     else {
  20.         char wd[MAXPATHLEN];
  21.  
  22.         if (getwd(wd) == 0)
  23.             return 0;
  24.         else {
  25.             (void) strncpy(path, wd, size-1);
  26.             path[size-1] = '\0';
  27.             return path;
  28.         }
  29.     }
  30. }
  31.